<div class="site-dir"><?php
    echo $this->Html->link('Trang chủ', array('controller' => 'index', 'action' => 'index'));
    echo ' >> '.$this->Html->link('Đề cá nhân', array('controller' => 'tests', 'action' => 'viewall'));
    if(isset($subjectDir)) {
        echo ' >> '.$subjectDir['Subject']['name'];
    }
?></div>
<div class="form-style">
    <div class="subject-list"><?php
        foreach($testSubjectView as $subject) {
            echo $this->Html->link($this->Html->image('subjects/'.$subject['id'].'.gif'), array('controller' => 'tests', 'action' => 'viewall', $subject['id']), array('escape' => false));
        }
    ?></div>
    <h2>Đề cá nhân <?php if(isset($subjectDir)){echo '('.$subjectDir['Subject']['name'].')';}?></h2>
    <br />
    <table class="chomo-table" width="100%" cellspacing="0">
        <tr>
            <th><?php echo $this->Paginator->sort('id', 'Mã đề');?></th>
            <th><?php echo $this->Paginator->sort('subject_id', 'Nhóm đề');?></th>
            <th><?php echo $this->Paginator->sort('grade_id', 'Khối lớp');?></th>
            <th>Tên đề</th>
            <th align="center">Số câu</th>
            <th><?php echo $this->Paginator->sort('created', 'Ngày tạo');?></th>
            <th width="155">Thao tác</th>
        </tr>
    <?php if($test) {
        foreach($test as $t) {
    ?>
        <tr>
            <td align="center"><?php echo $this->Html->link($t['Test']['id'], array('controller' => 'tests', 'action' => 'view', $t['Test']['id']));?></td>
            <td align="center"><?php echo $this->Html->link($t['Subject']['name'], array('controller' => 'subjects', 'action' => 'view', $t['Subject']['id']));?></td>
            <td align="center"><?php echo $this->Html->link($t['Grade']['name'], array('controller' => 'subjects', 'action' => 'view', $t['Subject']['id'], $t['Grade']['id']));?></td>
            <td><?php echo $t['Test']['name']?></td>
            <td align="center"><?php
                if($t['Test']['question_updated'] != 0) {
                    echo $t['Test']['question_updated'].'<br />';
                    echo '<i>'.$t['Test']['normal_updated'].' tự luận</i>';
                } else {
                    echo 'Không có.';
                }
            ?></td>
            <td align="center"><?php echo $this->Time->format('G:i d/m/Y', $t['Test']['created']);?></td>
            <td align="center"><?php
                echo '<span class="action-button">'.$this->Html->link('Xem', array('controller' => 'tests', 'action' => 'view', $t['Test']['id'])).'</span>';
                if($t['Test']['share'] == 1) {
                    echo '<span class="action-button">'.$this->Html->link('Hủy chia sẻ', array('controller' => 'tests', 'action' => 'notshare', $t['Test']['id'])).'</span>';
                } else {
                    echo '<span class="action-button">'.$this->Html->link('Chia sẻ', array('controller' => 'tests', 'action' => 'share', $t['Test']['id'])).'</span>';
                }
                echo '<span class="action-button">'.$this->Html->link('Xóa', array('controller' => 'tests', 'action' => 'delete', $t['Test']['id'])).'</span>';
            ?></td>
        </tr>
    <?php
        }
    } else {?>
        <tr><td colspan="8" align="center">Bạn không có đề nào</td></tr>
    <?php }?>
    </table>
    <div class="paging">
        <?php
            echo $this->Paginator->first('Trang đầu');
            echo $this->Paginator->numbers(array('separator' => ''));
            echo $this->Paginator->last('Trang cuối');
        ?>
    </div>
    <table width="100%">
        <tr>
            <td><?php
                echo $this->Form->create(null, array('url' => array('controller' => 'tests', 'action' => 'add')));
                echo $this->Form->end('Tạo đề mới');
            ?></td>
        </tr>
        <tr><td><?php echo $this->Session->flash();?></td></tr>
    </table>
</div>